package engine

import (
	"encoding/json"
	"log"
)

type SimpleEngine struct {
}

func (e SimpleEngine) Run(seeds ...Request) {
	var requests []Request
	for _, request := range seeds {
		requests = append(requests, request)
	}

	for len(requests) > 0 {
		r := requests[0]
		requests = requests[1:]

		parseResult, err := Worker(r)
		if err != nil {
			continue
		}

		parseRequest := parseResult.Requests
		requests = append(parseRequest, requests...)

		for _, item := range parseResult.Items {
			marshal, err := json.Marshal(item)
			if err == nil {
				log.Printf("Got item %s", marshal)
			}
		}

	}
}
